
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pkg;

import Utility.PostOperationsUtility;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import xmlMapping.Post;

/**
 *
 * @author Emyzzz
 */
public class EditPostTagHandler extends SimpleTagSupport {
    private int postId;

    /**
     * Called by the container to invoke this tag.
     * The implementation of this method is provided by the tag library developer,
     * and handles all tag processing, body iteration, etc.
     */
    @Override
    public void doTag() throws JspException {
        System.out.println(" post id is to edit is                  --------- "+postId);
        Post post= new PostOperationsUtility().getPost(postId);
        getJspContext().setAttribute("title",post.getTitle(),PageContext.REQUEST_SCOPE);
        getJspContext().setAttribute("body",post.getBody(),PageContext.REQUEST_SCOPE);

    }

    public void setPostId(int postId) {
        System.out.println("setter inside post tag handler and post id= "+postId);
        this.postId = postId;
    }

}



